/**
 * WMS图标资源索引
 * 统一管理WMS系统中使用的图标
 */

// Element Plus图标映射
export const WmsIcons = {
  // 基础数据管理图标
  warehouse: 'OfficeBuilding',
  area: 'Grid',
  merchant: 'UserFilled',
  item: 'Box',
  category: 'Collection',
  brand: 'Star',
  
  // 库存管理图标
  inventory: 'Goods',
  stock: 'DataBoard',
  adjust: 'EditPen',
  allocate: 'Share',
  history: 'Clock',
  
  // 订单管理图标
  receipt: 'Download',
  shipment: 'Upload',
  movement: 'Switch',
  check: 'List',
  order: 'Document',
  
  // 报表统计图标
  report: 'DataAnalysis',
  chart: 'PieChart',
  trend: 'TrendCharts',
  export: 'Download',
  
  // 操作图标
  add: 'Plus',
  edit: 'Edit',
  delete: 'Delete',
  view: 'View',
  search: 'Search',
  refresh: 'Refresh',
  save: 'Check',
  cancel: 'Close',
  
  // 状态图标
  success: 'SuccessFilled',
  warning: 'WarningFilled',
  error: 'CircleCloseFilled',
  info: 'InfoFilled',
  
  // 功能图标
  setting: 'Setting',
  filter: 'Filter',
  sort: 'Sort',
  print: 'Printer',
  import: 'Upload',
  
  // 导航图标
  home: 'HomeFilled',
  back: 'ArrowLeft',
  forward: 'ArrowRight',
  up: 'ArrowUp',
  down: 'ArrowDown',
  
  // 其他图标
  loading: 'Loading',
  more: 'MoreFilled',
  help: 'QuestionFilled',
  lock: 'Lock',
  unlock: 'Unlock'
} as const

// 图标类型定义
export type WmsIconType = keyof typeof WmsIcons

// 获取图标名称的工具函数
export function getWmsIcon(iconType: WmsIconType): string {
  return WmsIcons[iconType]
}

// 图标分类
export const WmsIconCategories = {
  basic: ['warehouse', 'area', 'merchant', 'item', 'category', 'brand'],
  inventory: ['inventory', 'stock', 'adjust', 'allocate', 'history'],
  order: ['receipt', 'shipment', 'movement', 'check', 'order'],
  report: ['report', 'chart', 'trend', 'export'],
  action: ['add', 'edit', 'delete', 'view', 'search', 'refresh', 'save', 'cancel'],
  status: ['success', 'warning', 'error', 'info'],
  function: ['setting', 'filter', 'sort', 'print', 'import'],
  navigation: ['home', 'back', 'forward', 'up', 'down'],
  other: ['loading', 'more', 'help', 'lock', 'unlock']
} as const

// 图标颜色主题
export const WmsIconColors = {
  primary: '#409eff',
  success: '#67c23a',
  warning: '#e6a23c',
  danger: '#f56c6c',
  info: '#909399',
  text: {
    primary: '#303133',
    regular: '#606266',
    secondary: '#909399',
    placeholder: '#a8abb2'
  }
} as const

// 图标尺寸
export const WmsIconSizes = {
  xs: '12px',
  sm: '14px',
  md: '16px',
  lg: '18px',
  xl: '20px',
  xxl: '24px'
} as const

// 常用图标组合
export const WmsIconCombinations = {
  // 仓库相关
  warehouseManagement: ['warehouse', 'setting'],
  warehouseStats: ['warehouse', 'chart'],
  
  // 库存相关
  inventoryAlert: ['inventory', 'warning'],
  inventoryHistory: ['inventory', 'history'],
  
  // 订单相关
  orderProcess: ['order', 'loading'],
  orderComplete: ['order', 'success'],
  
  // 操作相关
  addNew: ['add', 'success'],
  editItem: ['edit', 'warning'],
  deleteItem: ['delete', 'danger'],
  
  // 报表相关
  exportReport: ['export', 'success'],
  printReport: ['print', 'info']
} as const

// 图标工具类
export class WmsIconUtils {
  /**
   * 根据状态获取对应的图标
   */
  static getStatusIcon(status: 'success' | 'warning' | 'error' | 'info'): string {
    return WmsIcons[status]
  }
  
  /**
   * 根据操作类型获取对应的图标
   */
  static getActionIcon(action: 'add' | 'edit' | 'delete' | 'view' | 'search' | 'refresh'): string {
    return WmsIcons[action]
  }
  
  /**
   * 根据模块获取对应的图标
   */
  static getModuleIcon(module: 'warehouse' | 'area' | 'merchant' | 'item' | 'inventory' | 'order' | 'report'): string {
    return WmsIcons[module]
  }
  
  /**
   * 获取图标的CSS类名
   */
  static getIconClass(iconType: WmsIconType, size?: keyof typeof WmsIconSizes): string {
    const baseClass = `el-icon-${WmsIcons[iconType]}`
    const sizeClass = size ? `wms-icon-${size}` : ''
    return [baseClass, sizeClass].filter(Boolean).join(' ')
  }
  
  /**
   * 获取图标的内联样式
   */
  static getIconStyle(color?: string, size?: string): Record<string, string> {
    const style: Record<string, string> = {}
    
    if (color) {
      style.color = color
    }
    
    if (size) {
      style.fontSize = size
    }
    
    return style
  }
}

// 导出默认配置
export default {
  icons: WmsIcons,
  categories: WmsIconCategories,
  colors: WmsIconColors,
  sizes: WmsIconSizes,
  combinations: WmsIconCombinations,
  utils: WmsIconUtils
}
